import {BaseUrl} from "../constant/constant";
import {ApiFetch} from "../api/apiHandler";

class WithdrawModel {

    constructor() {
        this.url = BaseUrl
    }

    all(params) {
        let end = this.url + 'getbalanceapply'
        let req = new ApiFetch(end)
        return req.fetch(params)
    }

    check(params) {
        let end = this.url + 'checkbalanceapply'
        let req = new ApiFetch(end)
        return req.fetch(params)
    }

    set(params) {
        let end = this.url + 'setbalanceapply'
        let req = new ApiFetch(end)
        return req.fetch(params)
    }

    download(params) {

        let end = this.url + 'downloadbalanceapply?'
        const entries = Object.entries(params)
        entries.map(([k, v], i) => {
            end += `${k}=${v}`
            if (i !== entries.length - 1) {
                end += '&'
            }
        })
        const link = document.createElement('a')
        link.href = end
        link.click()
        // let req = new ApiFetch(end)
        // return req.fetch({}, 'get')
    }
}

export default WithdrawModel